// src/stores/category.js
import { defineStore } from 'pinia';
import apiService from '@/services/api';

export const useCategoryStore = defineStore('category', {
  state: () => ({
    categories: []
  }),
  actions: {
    async fetchCategories() {
      try {
        const response = await apiService.getAllItems({ typeIndex: 5 });
        this.categories = response;
        return response;
      } catch (error) {
        console.error('Failed to fetch categories:', error);
        throw error;
      }
    }
  }
});